﻿<Application x:Class="Synrc.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
   	xmlns:local="clr-namespace:Synrc"
	xmlns:clr="clr-namespace:System;assembly=mscorlib"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    StartupUri="AddressBookWindow.xaml">

    <Application.Resources>
        
        <!-- Smooth Scrolling and Spliiter Styles are Application and Synrc Global -->

        <local:ColumnViewportConverter x:Key="columnViewportConverter"/>
        <clr:Double x:Key="columnHeight">50</clr:Double>

    	<Style x:Key="{x:Static GridView.GridViewScrollViewerStyleKey}"
    		TargetType="{x:Type ScrollViewer}">
			<Setter Property="Focusable" Value="false"/>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type ScrollViewer}">
						<Grid SnapsToDevicePixels="true" Background="{TemplateBinding Background}">
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="*"/>
								<ColumnDefinition Width="Auto"/>
							</Grid.ColumnDefinitions>
							<Grid.RowDefinitions>
								<RowDefinition Height="*"/>
								<RowDefinition Height="Auto"/>
							</Grid.RowDefinitions>
							<DockPanel Margin="{TemplateBinding Padding}">
								<ScrollViewer Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" DockPanel.Dock="Top">
									<GridViewHeaderRowPresenter x:Name="viewHeaderRowPresenter"
											Margin="2,0,2,0"
											Columns="{Binding Path=TemplatedParent.View.Columns, RelativeSource={RelativeSource TemplatedParent}}"
											ColumnHeaderContainerStyle="{Binding Path=TemplatedParent.View.ColumnHeaderContainerStyle, RelativeSource={RelativeSource TemplatedParent}}"
											ColumnHeaderTemplate="{Binding Path=TemplatedParent.View.ColumnHeaderTemplate, RelativeSource={RelativeSource TemplatedParent}}"
											ColumnHeaderTemplateSelector="{Binding Path=TemplatedParent.View.ColumnHeaderTemplateSelector, RelativeSource={RelativeSource TemplatedParent}}"
											AllowsColumnReorder="{Binding Path=TemplatedParent.View.AllowsColumnReorder, RelativeSource={RelativeSource TemplatedParent}}"
											ColumnHeaderContextMenu="{Binding Path=TemplatedParent.View.ColumnHeaderContextMenu, RelativeSource={RelativeSource TemplatedParent}}"
											ColumnHeaderToolTip="{Binding Path=TemplatedParent.View.ColumnHeaderToolTip, RelativeSource={RelativeSource TemplatedParent}}"
											SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
								</ScrollViewer>
								
								<ScrollContentPresenter x:Name="PART_ScrollContentPresenter"
											SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"											
											ContentTemplate="{TemplateBinding ContentTemplate}"
											KeyboardNavigation.DirectionalNavigation="Local"
											CanContentScroll="{TemplateBinding CanContentScroll}">
								
									<ScrollContentPresenter.Content>
										<Grid>

											<!--Container of vertical and horizontal lines--> 

											<ItemsControl Margin="3,0,0,0" ItemsSource="{Binding Path=TemplatedParent.View.Columns, RelativeSource={RelativeSource TemplatedParent}}">
												<ItemsControl.ItemTemplate>
													<DataTemplate>
														<Border Width="{Binding Path=ActualWidth}" BorderThickness="0,0,1,0" BorderBrush="{DynamicResource verticalLineColor}" />
													</DataTemplate>
												</ItemsControl.ItemTemplate>
												<ItemsControl.ItemsPanel>
													<ItemsPanelTemplate>
														<StackPanel Orientation="Horizontal" />
													</ItemsPanelTemplate>
												</ItemsControl.ItemsPanel>
												
												 <!--Fill background with horizontal lines--> 

												<ItemsControl.Background>
													<VisualBrush TileMode="Tile" Stretch="None" Viewport="{Binding Source={StaticResource columnHeight}, Converter={StaticResource columnViewportConverter}}"  ViewportUnits="Absolute">
														<VisualBrush.Visual>
															<StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                                                                
																<!--Add Rectangles here for more horizontal lines--> 
                                                                
																<Rectangle Height="{DynamicResource columnHeight}" VerticalAlignment="Stretch" Fill="{DynamicResource horizontalLineColor1}" Width="1" />
																<Rectangle Height="{DynamicResource columnHeight}" VerticalAlignment="Stretch" Fill="{DynamicResource horizontalLineColor2}" Width="1"  />
															</StackPanel>
														</VisualBrush.Visual>
													</VisualBrush>
												</ItemsControl.Background>		
											</ItemsControl>
											<ContentControl Content="{TemplateBinding Content}" />
										</Grid>
									</ScrollContentPresenter.Content>										
								</ScrollContentPresenter>

							</DockPanel>
							<ScrollBar Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Cursor="Arrow" x:Name="PART_HorizontalScrollBar" Grid.Row="1" Maximum="{TemplateBinding ScrollableWidth}" Minimum="0.0" Value="{Binding Path=HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" Orientation="Horizontal" ViewportSize="{TemplateBinding ViewportWidth}"/>
							<ScrollBar Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Cursor="Arrow" x:Name="PART_VerticalScrollBar" Grid.Column="1" Maximum="{TemplateBinding ScrollableHeight}" Minimum="0.0" Value="{Binding Path=VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" Orientation="Vertical" ViewportSize="{TemplateBinding ViewportHeight}"/>
							<DockPanel Grid.Column="1" Grid.Row="1" Background="{Binding Path=Background, ElementName=PART_VerticalScrollBar}" LastChildFill="false">
								<Rectangle Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Width="1" Fill="White" DockPanel.Dock="Left"/>
								<Rectangle Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Height="1" Fill="White" DockPanel.Dock="Top"/>
							</DockPanel>
						</Grid>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>

        <LinearGradientBrush x:Key="splitterBrush" StartPoint="1,0" EndPoint="1,1">
            <GradientStop Color="Gray" Offset="0" />
            <GradientStop Color="Transparent" Offset="1.5"/>
        </LinearGradientBrush>

        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1" x:Key="panelBackgroundBrush">
            <LinearGradientBrush.GradientStops>
                <GradientStop Color="Transparent" Offset="0" />
                <GradientStop Color="Transparent" Offset="0.2" />
                <GradientStop Color="#FFAFD2FF" Offset="0.5" />
                <GradientStop Color="Transparent" Offset="0.8" />
                <GradientStop Color="Transparent" Offset="1" />
            </LinearGradientBrush.GradientStops>
        </LinearGradientBrush>

        <Style x:Key="gridSplitterStyle" TargetType="{x:Type GridSplitter}">
            <Setter Property="FrameworkElement.Width" Value="4"/>
            <Setter Property="TextElement.Foreground" Value="#FF204D89" />
            <Setter Property="Border.BorderBrush" Value="#FF6593CF" />
            <Setter Property="Panel.Background" Value="{StaticResource panelBackgroundBrush}" />
            <Setter Property="Border.BorderThickness" Value="0,1,0,0" />
            <Setter Property="UIElement.SnapsToDevicePixels" Value="True" />
            <Setter Property="UIElement.Focusable" Value="False" />
            <Setter Property="FrameworkElement.Cursor" Value="SizeNS" />
            <Setter Property="Control.Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Border 
                            BorderThickness="{TemplateBinding Border.BorderThickness}"
                            BorderBrush="{TemplateBinding Border.BorderBrush}"
                            Background="{TemplateBinding Panel.Background}">
                         <Border
                             BorderThickness="0,0,0,0"
                             BorderBrush="{StaticResource panelBackgroundBrush}">
                                <Canvas Width="3" Height="40">
                                    <Rectangle Fill="{StaticResource panelBackgroundBrush}" Width="2" Height="2" Canvas.Top="1" Canvas.Left="0" />
                                    <Rectangle Fill="{StaticResource panelBackgroundBrush}" Width="2" Height="2" Canvas.Top="5" Canvas.Left="0" />
                                    <Rectangle Fill="{StaticResource panelBackgroundBrush}" Width="2" Height="2" Canvas.Top="9" Canvas.Left="0" />
                                    <Rectangle Fill="{StaticResource panelBackgroundBrush}" Width="2" Height="2" Canvas.Top="13" Canvas.Left="0" />
                                    <Rectangle Fill="{StaticResource panelBackgroundBrush}" Width="2" Height="2" Canvas.Top="17" Canvas.Left="0" />
                                    <Rectangle Fill="{TemplateBinding TextElement.Foreground}" Width="2" Height="2" Canvas.Top="0" Canvas.Left="0" />
                                    <Rectangle Fill="{TemplateBinding TextElement.Foreground}" Width="2" Height="2" Canvas.Top="4" Canvas.Left="0" />
                                    <Rectangle Fill="{TemplateBinding TextElement.Foreground}" Width="2" Height="2" Canvas.Top="8" Canvas.Left="0" />
                                    <Rectangle Fill="{TemplateBinding TextElement.Foreground}" Width="2" Height="2" Canvas.Top="12" Canvas.Left="0" />
                                    <Rectangle Fill="{TemplateBinding TextElement.Foreground}" Width="2" Height="2" Canvas.Top="16" Canvas.Left="0" />
                                </Canvas>
                            </Border>
                        </Border>

                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Background">
                                <Setter.Value>
                                    <LinearGradientBrush StartPoint="1,0" EndPoint="1,1">
                                        <GradientStop Color="Gray" Offset="0" />
                                        <GradientStop Color="Transparent" Offset="1.5"/>
                                    </LinearGradientBrush>
                                </Setter.Value>
                            </Setter>
                            </Trigger>
                        </ControlTemplate.Triggers>
     
                    </ControlTemplate>
                </Setter.Value>
            </Setter>

        </Style>
        
    </Application.Resources>
</Application>
